#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int is_leap_year(int y)
{
    if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0)
    {
        return 1;
    }
    return 0;
}

int main()
{
    int a[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
    int y, m, d;
    while (scanf("%d %d %d", &y, &m, &d) != EOF)
    {
        int today = d;
        if (is_leap_year(y) && m > 2)
        {
            today += 1;
        }
        for (int i = m - 1; i > 0; i--)
        {
            today += a[i];
        }
        printf("%d\n", today);
    }
    return 0;
}